package com.hupu.jrs.widget

import android.content.Context
import android.graphics.Canvas
import android.support.v7.widget.CardView
import android.util.AttributeSet

/**
 * Created by sll on 2016/5/9.
 */
class LabelCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : CardView(context, attrs, defStyleAttr) {
    internal var utils: LabelViewHelper

    var labelHeight: Int
        get() = utils.labelHeight
        set(height) = utils.setLabelHeight(this, height)

    var labelDistance: Int
        get() = utils.labelDistance
        set(distance) = utils.setLabelDistance(this, distance)

    var isLabelVisual: Boolean
        get() = utils.isLabelVisual
        set(enable) = utils.setLabelVisual(this, enable)

    var labelOrientation: Int
        get() = utils.labelOrientation
        set(orientation) = utils.setLabelOrientation(this, orientation)

    var labelTextColor: Int
        get() = utils.labelTextColor
        set(textColor) = utils.setLabelTextColor(this, textColor)

    var labelBackgroundColor: Int
        get() = utils.labelBackgroundColor
        set(backgroundColor) = utils.setLabelBackgroundColor(this, backgroundColor)

    var labelText: String?
        get() = utils.labelText
        set(text) = utils.setLabelText(this, text!!)

    var labelTextSize: Int
        get() = utils.labelTextSize
        set(textSize) = utils.setLabelTextSize(this, textSize)

    init {
        utils = LabelViewHelper(context, attrs!!, defStyleAttr)
    }

    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)
        utils.onDraw(canvas, measuredWidth, measuredHeight)
    }
}
